class_name UIGameEnd
extends Control

@onready var title: Label = $Title/Title
@onready var animation_player: AnimationPlayer = $AnimationPlayer
var is_show_message_finish: bool = false
var is_returned: bool = false


func show_fail_message():
	title.text = "没关系，不妨再来一次"
	animation_player.play("show_info")
	await animation_player.animation_finished
	is_show_message_finish = true
	animation_player.play("flicker_continue")
	

func show_finish_message():
	title.text = "恭喜通关，感谢体验"
	animation_player.play("show_info")
	await animation_player.animation_finished
	is_show_message_finish = true
	animation_player.play("flicker_continue")
	

func _process(delta: float) -> void:
	process_return()
	
	
func process_return():
	if not is_show_message_finish: return
	if is_returned: return
	
	if Input.is_action_just_pressed("use"):
		is_returned = true
		AudioManager.play_sound("sfx_menubuttonclick")
		animation_player.play("hide_info")
		await animation_player.animation_finished
		LevelManager.transition_2("title_level")
		
	
	
	
	
